package com.yxq.mdt.app.modules.socialcontact.adapter;


import android.app.Activity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bigkoo.convenientbanner.utils.ScreenUtil;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.socialcontact.bean.SocialPersonalHomepageBean;
import com.yxq.mdt.app.utils.DisplayUtil;

import java.util.List;

public class SocialPhotoAdapter extends BaseQuickAdapter<SocialPersonalHomepageBean.PhotoImgFileBean, BaseViewHolder> {
    boolean selfUser;//是否是登录用户
    public SocialPhotoAdapter(Activity activity, boolean self, int layoutResId, @Nullable List<SocialPersonalHomepageBean.PhotoImgFileBean> data) {
        super(layoutResId, data);
        this.selfUser = self;
    }

    @Override
    protected void convert(BaseViewHolder helper, SocialPersonalHomepageBean.PhotoImgFileBean item) {
        ImageView imageView = helper.getView(R.id.panic_tv_photo_img);
        ImageView imageView1 = helper.getView(R.id.item_iv_delete);
        TextView text = helper.getView(R.id.text);
        if (item.getId() == -1) {
            //上传图标
            imageView.setImageResource(R.mipmap.icon_seeting_img);
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
            helper.setGone(R.id.item_iv_delete, false);
        } else {
            if (selfUser) {
                //登录用户自己的相册 显示全部图片
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                imageView1.setVisibility(View.VISIBLE);
                text.setVisibility(View.GONE);
                imageView.setVisibility(View.VISIBLE);
                GlideHelper.setLoadRoundAttentionImage(mContext, item.getFilePath(), 0, imageView);
            } else {
                if (item.getShowStatus() == 1) {
                    // 1 显示图片 0 不显示
                    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                    imageView1.setVisibility(View.GONE);
                    text.setVisibility(View.GONE);
                    imageView.setVisibility(View.VISIBLE);
                    GlideHelper.setLoadRoundAttentionImage(mContext, item.getFilePath(), 0, imageView);
                } else {
                    //隐藏图片
                    imageView1.setVisibility(View.GONE);
                    text.setVisibility(View.VISIBLE);
                    imageView.setVisibility(View.GONE);
                    helper.addOnClickListener(R.id.text);
                }
            }

        }


        helper.addOnClickListener(R.id.panic_tv_photo_img);
        helper.addOnClickListener(R.id.item_iv_delete);
    }
}
